const AccessTokenKey = 'ACCESS_TOKEN_';
const RefreshTokenKey = 'REFRESH_TOKEN_';
const OpenIdKey = 'OPEN_ID_';
const UserCodeKey = 'USER_CODE_';
const TenantIdKey = 'TENANT_ID_';
const DicDataKey = 'DIC_DATA_';
const DriverIdKey = 'DRIVER_ID';
const AccountIdentityKey = 'ACCOUNT_IDENTITY';
// TODO 需不需要REFRESH_TOKEN

// ========== Token 相关 ==========

export function getAccessToken() {
  return uni.getStorageSync(AccessTokenKey);
}

export function getRefreshToken() {
  return uni.getStorageSync(RefreshTokenKey);
}

export function setToken(token) {
  uni.setStorageSync(AccessTokenKey, token.accessToken);
  uni.setStorageSync(RefreshTokenKey, token.refreshToken);
}

export function removeToken() {
  uni.removeStorageSync(AccessTokenKey);
  uni.removeStorageSync(RefreshTokenKey);
}

// ========== weixin 相关 ==========
export function getOpenId() {
  return uni.getStorageSync(OpenIdKey);
}
export function setOpenId(data) {
  uni.setStorageSync(OpenIdKey, data);
}
export function removeOpenId() {
  uni.removeStorageSync(OpenIdKey);
}

export function getUserCode() {
  return uni.getStorageSync(UserCodeKey);
}
export function setUserCode(data) {
  uni.setStorageSync(UserCodeKey, data);
}
export function removeUserCode() {
  uni.removeStorageSync(UserCodeKey);
}
//司机id
export function getDriverId() {
  return uni.getStorageSync(DriverIdKey);
}
export function setDriverId(data) {
  uni.setStorageSync(DriverIdKey, data);
}
//租户id
export function getTenantId() {
  return uni.getStorageSync(TenantIdKey);
}
export function setTenantId(data) {
  uni.setStorageSync(TenantIdKey, data);
}
export function removeTenantId() {
  uni.removeStorageSync(TenantIdKey);
}

// DicDataKey 字典数据
export function getDicData() {
  return uni.getStorageSync(DicDataKey);
}
export function setDicData(data) {
  uni.setStorageSync(DicDataKey, data);
}
export function removeDicData() {
  uni.removeStorageSync(DicDataKey);
}

// 采购销售识别码
export function getAccountIdentity() {
  return uni.getStorageSync(AccountIdentityKey);
}
export function setAccountIdentity(code) {
  uni.setStorageSync(AccountIdentityKey, code);
}
export function removeAccountIdentity() {
  uni.removeStorageSync(AccountIdentityKey);
}

export function clearStorageSync() {
  uni.clearStorageSync();
}
